** Clean FHFA housing price indices 
** JHL

*************************************
** Set up workspace
*************************************
version 14.1
clear all
set more off

cd "${path_home}"
adopath + ../programs
** log using "${path_log}/c04_clean_housing_prices", text replace

*************************************
** Start work here
*************************************

timer on 1 

*************************************
** [1] Clean FHFA housing prices 
*************************************

import excel "${path_big_dta}/fhfa/HPI_AT_3zip.xlsx", sheet("Three-Digit ZIP All-Trans") cellrange(A5:E76739) firstrow clear 
** Some extrapolated from larger indices 
ta IndexT
destring Three, gen(zip3)
drop Three 
rename (Year Quarter) (year quarter)
la var IndexNSA "all-transactions fhfa zip3 index, non seasonally adjusted"
rename IndexNSA hp_zip3_at_nsa 
save "${path_big_dta}/fhfa/HPI_AT_3zip", replace

*************************************
** Close workspace
*************************************
** log close
timer off 1
timer list 1 

